home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cocktail
/
cg.lha
/
cg
/
src
/
GramMod.mi
< prev
next >
Wrap
Text File
|
1992-11-24
|
23KB
|
1,131 lines
IMPLEMENTATION MODULE GramMod;
IMPORT SYSTEM, System, IO, Tree;
(* line 5 "" *)
FROM IO IMPORT WriteS, WriteNl;
FROM Strings IMPORT tString, ArrayToString;
FROM StringMem IMPORT WriteString;
FROM Idents IMPORT NoIdent, tIdent, MakeIdent;
FROM Texts IMPORT WriteText;
FROM Sets IMPORT IsElement, Include;
FROM TreeMod2 IMPORT TreeIO;
FROM Tree IMPORT
NoTree , tTree , Input , Reverse ,
Class , NoClass , Child , Attribute ,
ActionPart , HasSelector , HasAttributes , NoCodeAttr ,
Referenced , Options , TreeRoot , QueryTree ,
ClassCount , iNoTree , itTree , Generated ,
f , WI, WE, WN , ForallClasses , ForallAttributes,
Nonterminal , Terminal , IdentifyAttribute,
String , iPosition ;
IMPORT Strings;
VAR
Node, ActClass, TheClass, TheAttr : tTree;
iOper, iLeft, iRight, iNone, iPrec, iRule : tIdent;
ActActionIndex, PrevActionIndex, i : SHORTCARD;
IsImplicit : BOOLEAN;
s : tString;
PROCEDURE GetBaseClass (Class: tTree): tTree;
BEGIN
WHILE Class^.Class.BaseClass^.Kind # NoClass DO
Class := Class^.Class.BaseClass;
END;
RETURN Class;
END GetBaseClass;
PROCEDURE IsLast (Class, Action: tTree): BOOLEAN;
VAR Found, Last: BOOLEAN;
BEGIN
IsLast2 (Class, Action, Found, Last);
RETURN Last;
END IsLast;
PROCEDURE IsLast2 (t, Action: tTree; VAR pFound, pLast: BOOLEAN);
VAR Found, Last: BOOLEAN;
BEGIN
CASE t^.Kind OF
| Class:
IsLast2 (t^.Class.Attributes, Action, pFound, pLast);
IF pFound OR NOT pLast THEN RETURN; END;
IsLast2 (t^.Class.BaseClass, Action, pFound, pLast);
| Child:
IsLast2 (t^.Child.Next, Action, Found, Last);
pFound := Found;
IF Found THEN
pLast := Last;
ELSE
pLast := FALSE;
END;
| Attribute:
IsLast2 (t^.Attribute.Next, Action, pFound, pLast);
| ActionPart:
IsLast2 (t^.ActionPart.Next, Action, Found, Last);
pFound := Found OR (Action = t);
IF Found THEN
pLast := Last;
ELSE
pLast := Last AND (Action = t);
END;
ELSE
pFound := FALSE;
pLast := TRUE;
END;
END IsLast2;
PROCEDURE yyAbort (yyFunction: ARRAY OF CHAR);
BEGIN
IO.WriteS (IO.StdError, 'Error: module GramMod, routine ');
IO.WriteS (IO.StdError, yyFunction);
IO.WriteS (IO.StdError, ' failed');
IO.WriteNl (IO.StdError);
Exit;
END yyAbort;
PROCEDURE yyIsEqual (yya, yyb: ARRAY OF SYSTEM.BYTE): BOOLEAN;
VAR yyi : INTEGER;
BEGIN
FOR yyi := 0 TO INTEGER (HIGH (yya)) DO
IF yya [yyi] # yyb [yyi] THEN RETURN FALSE; END;
END;
RETURN TRUE;
END yyIsEqual;
PROCEDURE ParsSpec (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Ag) THEN
(* line 93 "" *)
WITH t^.Ag DO
(* line 93 "" *)
IF ScannerName # NoIdent THEN
WriteS (f, "SCANNER "); WI (ScannerName);
END;
WriteS (f, " PARSER "); WI (ParserName); WriteNl (f);
WriteS (f, "GLOBAL {"); WriteNl (f);
WriteText (f, ParserCodes^.Codes.Global);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteText (f, Node^.Module.ParserCodes^.Codes.Global);
Node := Node^.Module.Next;
END;
WriteS (f, "TYPE"); WriteNl (f);
ParsVariant (Classes);
WriteNl (f);
WriteS (f, "tParsAttribute = RECORD CASE : SHORTCARD OF"); WriteNl (f);
WriteS (f, " 0: Scan: ");
IF ScannerName # NoIdent THEN WI (ScannerName); ELSE WriteS (f, "Scanner"); END;
WriteS (f, ".tScanAttribute;"); WriteNl (f);
i := 0;
Node := Classes;
WHILE Node^.Kind = Class DO
WITH Node^.Class DO
IF {Nonterminal, Referenced, HasAttributes} <= Properties THEN
INC (i);
WriteS (f, "| "); WN (i); WriteS (f, ": ");
IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
WriteS (f, "(* "); WE (Name); WriteS (f, " *) yy"); WN (Name);
WriteS (f, ": yy"); WN (Name); WriteS (f, ";"); WriteNl (f);
ELSE
WI (Selector); WriteS (f, ": yy"); WI (Selector); WriteS (f, ";"); WriteNl (f);
END;
END;
Node := Next;
END;
END;
WriteS (f, "END; END;"); WriteNl (f);
WriteS (f, "}"); WriteNl (f);
WriteNl (f);
WriteS (f, "EXPORT {"); WriteNl (f);
WriteText (f, ParserCodes^.Codes.Export);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteText (f, Node^.Module.ParserCodes^.Codes.Export);
Node := Node^.Module.Next;
END;
WriteS (f, "}"); WriteNl (f);
WriteNl (f);
WriteS (f, "LOCAL {"); WriteNl (f);
WriteText (f, ParserCodes^.Codes.Local);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteText (f, Node^.Module.ParserCodes^.Codes.Local);
Node := Node^.Module.Next;
END;
WriteS (f, "}"); WriteNl (f);
WriteNl (f);
WriteS (f, "BEGIN {"); WriteNl (f);
WriteText (f, ParserCodes^.Codes.Begin);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteText (f, Node^.Module.ParserCodes^.Codes.Begin);
Node := Node^.Module.Next;
END;
WriteS (f, "}"); WriteNl (f);
WriteNl (f);
WriteS (f, "CLOSE {"); WriteNl (f);
WriteText (f, ParserCodes^.Codes.Close);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteText (f, Node^.Module.ParserCodes^.Codes.Close);
Node := Node^.Module.Next;
END;
WriteS (f, "}"); WriteNl (f);
WriteNl (f);
WriteS (f, "TOKEN"); WriteNl (f);
WriteNl (f);
ForallClasses (Classes, Token);
WriteNl (f);
WriteS (f, "OPER"); WriteNl (f);
WriteNl (f);
PrecDefs (Precs);
WriteNl (f);
WriteS (f, "RULE"); WriteNl (f);
WriteNl (f);
ForallClasses (Classes, ParsSpec);
;
RETURN;
END;
END;
IF (t^.Kind = Tree.Class) THEN
(* line 180 "" *)
WITH t^.Class DO
(* line 180 "" *)
IF {Nonterminal, Referenced} <= Properties THEN
TheClass := t;
Grammar (t);
END;
;
RETURN;
END;
END;
END ParsSpec;
PROCEDURE ScanSpec (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Ag) THEN
(* line 190 "" *)
WITH t^.Ag DO
(* line 190 "" *)
WriteS (f, "m"); WriteNl (f);
WriteS (f, "TYPE"); WriteNl (f);
ForallClasses (Classes, ScanVariant);
WriteNl (f);
WriteS (f, "tScanAttribute = RECORD"); WriteNl (f);
WriteS (f, "Position: tPosition;"); WriteNl (f);
WriteS (f, "CASE : SHORTCARD OF"); WriteNl (f);
ForallClasses (Classes, ScanAttr);
WriteS (f, "END; END;"); WriteNl (f);
WriteNl (f);
WriteS (f, "PROCEDURE ErrorAttribute (Token: INTEGER; VAR pAttribute: tScanAttribute);"); WriteNl (f);
WriteS (f, "%%"); WriteNl (f);
WriteS (f, "PROCEDURE ErrorAttribute (Token: INTEGER; VAR pAttribute: tScanAttribute);"); WriteNl (f);
WriteS (f, "BEGIN"); WriteNl (f);
WriteS (f, " pAttribute.Position := Attribute.Position;"); WriteNl (f);
WriteS (f, " CASE Token OF"); WriteNl (f);
ForallClasses (Classes, ErrorActions);
WriteS (f, " ELSE"); WriteNl (f);
WriteS (f, " END;"); WriteNl (f);
WriteS (f, "END ErrorAttribute;"); WriteNl (f);
WriteS (f, "%%"); WriteNl (f);
ForallClasses (Classes, ScanSpec);
;
RETURN;
END;
END;
IF (t^.Kind = Tree.Class) THEN
(* line 214 "" *)
WITH t^.Class DO
(* line 214 "" *)
IF {Terminal, Referenced} <= Properties THEN
WN (Code);
IF HasAttributes IN Properties THEN WriteS (f, " S ");
ELSE WriteS (f, " N ");
END;
IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
WriteS (f, "yy"); WN (Code);
ELSE
WI (Selector);
END;
WriteS (f, " "); WI (Name); WriteNl (f);
END;
;
RETURN;
END;
END;
END ScanSpec;
PROCEDURE ErrorActions (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
CASE t^.Kind OF
| Tree.Class:
(* line 232 "" *)
WITH t^.Class DO
(* line 232 "" *)
IF {Terminal, Referenced, HasAttributes} <= Properties THEN
WriteS (f, " | (* "); WE (Name); WriteS (f, " *) "); WN (Code); WriteS (f, ": "); WriteNl (f);
TheClass := t;
ForallAttributes (t, ErrorActions);
END;
;
RETURN;
END;
| Tree.ActionPart:
(* line 239 "" *)
WITH t^.ActionPart DO
(* line 239 "" *)
ErrorActions (Actions);
;
RETURN;
END;
| Tree.Assign:
(* line 242 "" *)
WITH t^.Assign DO
(* line 242 "" *)
ErrorActions (Results); WriteS (f, ":="); ErrorActions (Arguments); WriteS (f, ";"); WriteNl (f);
ErrorActions (Next);
;
RETURN;
END;
| Tree.Copy:
(* line 246 "" *)
WITH t^.Copy DO
(* line 246 "" *)
ErrorActions (Results); WriteS (f, " := "); ErrorActions (Arguments); WriteS (f, ";"); WriteNl (f);
ErrorActions (Next);
;
RETURN;
END;
| Tree.TargetCode:
(* line 250 "" *)
WITH t^.TargetCode DO
(* line 250 "" *)
ErrorActions (Code); WriteS (f, ";"); WriteNl (f);
ErrorActions (Next);
;
RETURN;
END;
| Tree.Order:
(* line 254 "" *)
WITH t^.Order DO
(* line 254 "" *)
ErrorActions (Next);
;
RETURN;
END;
| Tree.Check:
(* line 257 "" *)
WITH t^.Check DO
(* line 257 "" *)
IF Statement # NoTree THEN
IF Condition # NoTree THEN
WriteS (f, "IF NOT ("); ErrorActions (Condition); WriteS (f, ") THEN "); ErrorActions (Statement); WriteS (f, "; END;"); WriteNl (f);
ELSE
ErrorActions (Statement); WriteS (f, ";"); WriteNl (f);
END;
ELSE
WriteS (f, "IF "); ErrorActions (Condition); WriteS (f, " THEN END;"); WriteNl (f);
END;
ErrorActions (Next);
;
RETURN;
END;
| Tree.Designator:
(* line 269 "" *)
WITH t^.Designator DO
(* line 269 "" *)
WI (Selector); WriteS (f, ":"); WI (Attribute);
ErrorActions (Next);
;
RETURN;
END;
| Tree.Ident:
(* line 273 "" *)
WITH t^.Ident DO
(* line 273 "" *)
TheAttr := IdentifyAttribute (TheClass, Attribute);
IF TheAttr # NoTree THEN
WriteS (f, "pAttribute");
IF Attribute = iPosition THEN
ELSIF (String IN TheClass^.Class.Properties) AND NOT (HasSelector IN TheClass^.Class.Properties) THEN
WriteS (f, ".yy"); WN (TheClass^.Class.Code);
ELSE
WriteS (f, "."); WI (TheClass^.Class.Selector);
END;
WriteS (f, ".");
END;
WI (Attribute);
ErrorActions (Next);
;
RETURN;
END;
| Tree.Any:
(* line 288 "" *)
WITH t^.Any DO
(* line 288 "" *)
WriteString (f, Code);
ErrorActions (Next);
;
RETURN;
END;
| Tree.Anys:
(* line 292 "" *)
WITH t^.Anys DO
(* line 292 "" *)
ErrorActions (Layouts);
ErrorActions (Next);
;
RETURN;
END;
| Tree.LayoutAny:
(* line 296 "" *)
WITH t^.LayoutAny DO
(* line 296 "" *)
WriteString (f, Code);
ErrorActions (Next);
;
RETURN;
END;
ELSE END;
END ErrorActions;
PROCEDURE ScanVariant (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 304 "" *)
WITH t^.Class DO
(* line 304 "" *)
IF {Terminal, Referenced, HasAttributes} <= Properties THEN
IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
WriteS (f, "(* "); WE (Name); WriteS (f, " *) yy"); WN (Code); WriteS (f, " = RECORD ");
ELSE
WriteS (f, "yy"); WI (Selector); WriteS (f, " = RECORD ");
END;
TheClass := t;
ForallAttributes (t, RecordField);
WriteS (f, "END;"); WriteNl (f);
END;
;
RETURN;
END;
END;
END ScanVariant;
PROCEDURE ScanAttr (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 320 "" *)
WITH t^.Class DO
(* line 320 "" *)
IF {Terminal, Referenced, HasAttributes} <= Properties THEN
WriteS (f, "| "); WN (Code); WriteS (f, ": ");
IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
WriteS (f, "(* "); WE (Name); WriteS (f, " *) yy"); WN (Code); WriteS (f, ": yy"); WN (Code); WriteS (f, ";"); WriteNl (f);
ELSE
WI (Selector); WriteS (f, ": yy"); WI (Selector); WriteS (f, ";"); WriteNl (f);
END;
END;
;
RETURN;
END;
END;
END ScanAttr;
PROCEDURE ParsVariant (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 334 "" *)
WITH t^.Class DO
(* line 334 "" *)
IF {Nonterminal, Referenced, HasAttributes} <= Properties THEN
IF (String IN Properties) AND NOT (HasSelector IN Properties) THEN
WriteS (f, "(* "); WE (Name); WriteS (f, " *) yy"); WN (Name); WriteS (f, " = RECORD ");
ELSE
WriteS (f, "yy"); WI (Selector); WriteS (f, " = RECORD ");
END;
TheClass := t;
ForallAttributes (Attributes, RecordField);
GenExt (Extensions);
WriteS (f, "END;"); WriteNl (f);
END;
ParsVariant (Next);
;
RETURN;
END;
END;
END ParsVariant;
PROCEDURE GenExt (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 352 "" *)
WITH t^.Class DO
(* line 352 "" *)
ForallAttributes (Attributes, RecordField);
GenExt (Extensions);
GenExt (Next);
;
RETURN;
END;
END;
END GenExt;
PROCEDURE Token (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 361 "" *)
WITH t^.Class DO
(* line 361 "" *)
IF {Terminal, Referenced} <= Properties THEN
WriteName (Name); WriteS (f, " = "); WN (Code); WriteNl (f);
END;
;
RETURN;
END;
END;
END Token;
PROCEDURE RecordField (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Attribute) THEN
(* line 370 "" *)
WITH t^.Attribute DO
(* line 370 "" *)
IF (NoCodeAttr * Properties) = {} THEN
IF (Nonterminal IN TheClass^.Class.Properties) OR (Name # iPosition) THEN
WI (Name); WriteS (f, ": "); WI (Type); WriteS (f, "; ");
END;
END;
;
RETURN;
END;
END;
END RecordField;
PROCEDURE PrecDefs (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.LeftAssoc) THEN
(* line 381 "" *)
WITH t^.LeftAssoc DO
(* line 381 "" *)
WriteS (f, "LEFT "); PrecDefs (Names); WriteNl (f);
PrecDefs (Next);
;
RETURN;
END;
END;
IF (t^.Kind = Tree.RightAssoc) THEN
(* line 385 "" *)
WITH t^.RightAssoc DO
(* line 385 "" *)
WriteS (f, "RIGHT"); PrecDefs (Names); WriteNl (f);
PrecDefs (Next);
;
RETURN;
END;
END;
IF (t^.Kind = Tree.NonAssoc) THEN
(* line 389 "" *)
WITH t^.NonAssoc DO
(* line 389 "" *)
WriteS (f, "NONE "); PrecDefs (Names); WriteNl (f);
PrecDefs (Next);
;
RETURN;
END;
END;
IF (t^.Kind = Tree.Name) THEN
(* line 393 "" *)
WITH t^.Name DO
(* line 393 "" *)
WriteS (f, " "); WI (Name);
PrecDefs (Next);
;
RETURN;
END;
END;
END PrecDefs;
PROCEDURE Grammar (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.Class) THEN
(* line 401 "" *)
WITH t^.Class DO
(* line 401 "" *)
IF Extensions^.Kind = Tree.NoClass THEN (* Low ? *)
WITH TheClass^.Class DO
IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WriteName (Name); END;
END;
WriteS (f, " : ");
ActClass := t;
PrevActionIndex := 0;
IsImplicit := FALSE;
ForallAttributes (t, Rule);
IF Prec # NoIdent THEN WriteS (f, "PREC "); WI (Prec); WriteS (f, " "); END;
WriteS (f, "."); WriteNl (f);
PrevActionIndex := 0;
IsImplicit := TRUE;
ForallAttributes (t, Implicit);
ELSE
Rule (Extensions);
END;
;
RETURN;
END;
END;
END Grammar;
PROCEDURE Rule (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
CASE t^.Kind OF
| Tree.Class:
(* line 424 "" *)
WITH t^.Class DO
(* line 424 "" *)
Grammar (t);
Rule (Next);
;
RETURN;
END;
| Tree.Child:
(* line 428 "" *)
WITH t^.Child DO
(* line 428 "" *)
IF {String, Nonterminal} <= Class^.Class.Properties THEN WriteS (f, "yy"); WN (Type); ELSE WriteName (Type); END; WriteS (f, " ");
;
RETURN;
END;
| Tree.ActionPart:
(* line 431 "" *)
WITH t^.ActionPart DO
(* line 431 "" *)
IF IsLast (ActClass, t) THEN
WriteS (f, "{");
IF PrevActionIndex # 0 THEN
Node := GetBaseClass (TheClass);
WITH Node^.Class DO
IF HasAttributes IN Properties THEN
WriteS (f, " $$.");
IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
WriteS (f, " := $"); WN (PrevActionIndex); WriteS (f, ".");
IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
WriteS (f, ";"); WriteNl (f);
END;
END;
END;
Rule (Actions);
WriteS (f, "} ");
ELSE
WriteS (f, "xx"); WN (Name); WriteS (f, " ");
END;
PrevActionIndex := ParsIndex;
;
RETURN;
END;
| Tree.Assign:
(* line 453 "" *)
WITH t^.Assign DO
(* line 453 "" *)
Rule (Results); WriteS (f, ":="); Rule (Arguments); WriteS (f, ";"); WriteNl (f);
Rule (Next);
;
RETURN;
END;
| Tree.Copy:
(* line 457 "" *)
WITH t^.Copy DO
(* line 457 "" *)
Rule (Results); WriteS (f, " := "); Rule (Arguments); WriteS (f, ";"); WriteNl (f);
Rule (Next);
;
RETURN;
END;
| Tree.TargetCode:
(* line 461 "" *)
WITH t^.TargetCode DO
(* line 461 "" *)
Rule (Code); WriteS (f, ";"); WriteNl (f);
Rule (Next);
;
RETURN;
END;
| Tree.Order:
(* line 465 "" *)
WITH t^.Order DO
(* line 465 "" *)
Rule (Next);
;
RETURN;
END;
| Tree.Check:
(* line 468 "" *)
WITH t^.Check DO
(* line 468 "" *)
IF Statement # NoTree THEN
IF Condition # NoTree THEN
WriteS (f, "IF NOT ("); Rule (Condition); WriteS (f, ") THEN "); Rule (Statement); WriteS (f, "; END;"); WriteNl (f);
ELSE
Rule (Statement); WriteS (f, ";"); WriteNl (f);
END;
ELSE
WriteS (f, "IF "); Rule (Condition); WriteS (f, " THEN END;"); WriteNl (f);
END;
Rule (Next);
;
RETURN;
END;
| Tree.Designator:
(* line 480 "" *)
WITH t^.Designator DO
(* line 480 "" *)
TheAttr := IdentifyAttribute (ActClass, Selector);
IF TheAttr # NoTree THEN
Node := TheAttr^.Child.Class;
IF Node # NoTree THEN
WriteS (f, "$");
IF NOT IsImplicit THEN
WN (TheAttr^.Child.ParsIndex);
ELSE
WN (SHORTINT (TheAttr^.Child.ParsIndex + 1 - ActActionIndex));
END;
IF Nonterminal IN Node^.Class.Properties THEN (* nonterminal *)
Node := GetBaseClass (Node);
IF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
WriteS (f, ".yy"); WN (Node^.Class.Name);
ELSE
WriteS (f, "."); WI (Node^.Class.Name);
END;
ELSE (* terminal *)
WriteS (f, ".Scan");
IF Attribute = iPosition THEN
ELSIF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
WriteS (f, ".yy"); WN (Node^.Class.Code);
ELSE
WriteS (f, "."); WI (Node^.Class.Selector);
END;
END;
WriteS (f, "."); WI (Attribute);
ELSE
WI (Selector); WriteS (f, ":"); WI (Attribute);
END;
ELSE
WI (Selector); WriteS (f, ":"); WI (Attribute);
END;
Rule (Next);
;
RETURN;
END;
| Tree.Ident:
(* line 516 "" *)
WITH t^.Ident DO
(* line 516 "" *)
TheAttr := IdentifyAttribute (ActClass, Attribute);
Node := GetBaseClass (TheClass);
IF TheAttr # NoTree THEN
IF (String IN Node^.Class.Properties) AND NOT (HasSelector IN Node^.Class.Properties) THEN
WriteS (f, "$$.yy"); WN (Node^.Class.Name); WriteS (f, "."); WI (Attribute);
ELSE
WriteS (f, "$$."); WI (Node^.Class.Name); WriteS (f, "."); WI (Attribute);
END;
ELSE
WI (Attribute);
END;
Rule (Next);
;
RETURN;
END;
| Tree.Any:
(* line 530 "" *)
WITH t^.Any DO
(* line 530 "" *)
WriteString (f, Code);
Rule (Next);
;
RETURN;
END;
| Tree.Anys:
(* line 534 "" *)
WITH t^.Anys DO
(* line 534 "" *)
Rule (Layouts);
Rule (Next);
;
RETURN;
END;
| Tree.LayoutAny:
(* line 538 "" *)
WITH t^.LayoutAny DO
(* line 538 "" *)
WriteString (f, Code);
Rule (Next);
;
RETURN;
END;
ELSE END;
END Rule;
PROCEDURE Implicit (t: Tree.tTree);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF t = Tree.NoTree THEN RETURN; END;
IF (t^.Kind = Tree.ActionPart) THEN
(* line 546 "" *)
WITH t^.ActionPart DO
(* line 546 "" *)
IF NOT (Generated IN Properties) AND NOT IsLast (ActClass, t) THEN
INCL (Properties, Generated);
ActActionIndex := ParsIndex;
WriteS (f, "xx"); WN (Name); WriteS (f, " : {");
IF PrevActionIndex # 0 THEN
Node := GetBaseClass (TheClass);
WITH Node^.Class DO
IF HasAttributes IN Properties THEN
WriteS (f, " $$.");
IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
WriteS (f, " := $"); WN (SHORTINT (PrevActionIndex + 1 - ActActionIndex)); WriteS (f, ".");
IF String IN Properties THEN WriteS (f, "yy"); WN (Name); ELSE WI (Name); END;
WriteS (f, ";"); WriteNl (f);
END;
END;
END;
Rule (Actions);
WriteS (f, "} ."); WriteNl (f);
END;
PrevActionIndex := ParsIndex;
;
RETURN;
END;
END;
END Implicit;
PROCEDURE WriteName (Name: tIdent);
VAR yyTempo: RECORD CASE : INTEGER OF
END; END;
BEGIN
IF (Name = (iOper)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
IF (Name = (iLeft)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
IF (Name = (iRight)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
IF (Name = (iNone)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
IF (Name = (iPrec)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
IF (Name = (iRule)) THEN
(* line 571 "" *)
(* line 576 "" *)
WriteS (f, "\");
(* line 576 "" *)
WI (Name);
RETURN;
END;
(* line 577 "" *)
(* line 577 "" *)
WI (Name);
RETURN;
END WriteName;
PROCEDURE BeginGramMod;
BEGIN
(* line 82 "" *)
ArrayToString ("OPER" , s); iOper := MakeIdent (s);
ArrayToString ("RIGHT" , s); iRight := MakeIdent (s);
ArrayToString ("LEFT" , s); iLeft := MakeIdent (s);
ArrayToString ("NONE" , s); iNone := MakeIdent (s);
ArrayToString ("PREC" , s); iPrec := MakeIdent (s);
ArrayToString ("RULE" , s); iRule := MakeIdent (s);
END BeginGramMod;
PROCEDURE CloseGramMod;
BEGIN
END CloseGramMod;
PROCEDURE yyExit;
BEGIN
IO.CloseIO; System.Exit (1);
END yyExit;
BEGIN
yyf := IO.StdOutput;
Exit := yyExit;
BeginGramMod;
END GramMod.